#ifndef PICTURESVIEW_H
#define PICTURESVIEW_H

#include <QGraphicsView>
#include <QSlider>
#include <QParallelAnimationGroup>
#include <QPropertyAnimation>
#include <QAbstractTransition>
#include <QLabel>
#include <QList>
#include <QTimeLine>
#include <QVector>
#include <QMouseEvent>
#include <QPushButton>
#include "pictureitem.h"
#include "mirrorpictureitem.h"
#include "PictureLoaderThread.h"
#include "SelectPictureItem.h"

#ifdef Q_OS_SYMBIAN
#include "symbianpicloader.h"

class PicturesView: public QGraphicsView, public MSymbianPicLoader
#else
class PicturesView : public QGraphicsView
#endif
{
    Q_OBJECT
    Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
public:
    explicit PicturesView(QGraphicsScene * scene, QWidget * parent = 0, int viewMode = 0);
    virtual ~PicturesView();

    void initButtons();
signals:
public slots:
    void scanDirectory(const QString& path);
    void initPictures();
    //void initMirrorItems(int midIndex);
    void midChanged(int midIndex, bool bSelect = false);
    void imageLoaded(QImage* image, PictureData* data);
    void selectImage(PictureData* data/*, bool bCloseBtns=true*/);
    void clearSelect(bool bCloseBtns=true);
    void selectPrevImage();
    void selectNextImage();
    void hideButtons();
    void exitAnimFinished();
    void scaleToggle(bool bChecked);
    void groupAnimFinished();
    void reset(int viewMode);

#ifdef Q_OS_SYMBIAN
    void thumbLoaded(QPixmap, PictureData*);
#endif

    /*void translateX(int value);
    void translateY(int value);
    void RotX(int value);
    void RotY(int value);
    void RotZ(int value);
    void Scale(int value);*/
private:
    void searchPicturesFromDevice(QString path);

protected:
    virtual void mouseMoveEvent ( QMouseEvent * event );
    virtual void mousePressEvent ( QMouseEvent * event );
    virtual void mouseReleaseEvent ( QMouseEvent * event );
private:
    QStringList mPicturesList;
    QPoint      mMousePos;

    //״̬
    QGraphicsItem*      mSelectItem;
    QPropertyAnimation* mAnim;
    int                 mViewMode;
    int                 mCount;
    int                 mGroupCount;
    bool                mIsScale;

    QVector<MirrorPictureItem*> mMirPictureItems;
    QList<PictureData*> mPictureDatas;
    PictureLoaderThread* mPictureLoaderThread;
    SelectPictureItem*   mSelectPicture;

    QPushButton* mExitBtn;
    QPushButton* mBackBtn;
    QPushButton* mScaleBtn;
    QPushButton* mRefreshBtn;
    QPushButton* mPrevBtn;
    QPushButton* mNextBtn;

    QPropertyAnimation* mExitBtnAnim;
    QPropertyAnimation* mScaleBtnAnim;
    QPropertyAnimation* mRefreshBtnAnim;
    QParallelAnimationGroup* mBtnsAnimGroup;
    QParallelAnimationGroup* mExitRefreshAnimGroup;
    QPropertyAnimation* mBackBtnAnim;
    QPropertyAnimation* mPrevBtnAnim;
    QPropertyAnimation* mNextBtnAnim;
    QPropertyAnimation* mViewAnim;


#ifdef Q_OS_SYMBIAN
    SymbianPicLoader*   mSymbianPicLoader;
#endif
};

#endif // PICTURESVIEW_H
